<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
	<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<form class="layui-form layui-form-pane">
	<div class="layui-form-item">
		<label class="layui-form-label">选择线路</label>
		<div class="layui-input-inline">
			<select name="busLine.lineId">
			<option value="">请选择</option>
				<c:forEach items="${busLineList }" var="item">
					<option value="${item.lineId }">${item.fullName}</option>
				</c:forEach>
			</select>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">起始时间</label>
		<div class="layui-input-inline">
			<input type="text" name="startTime" class="layui-input"
				id="startTime" readonly="readonly">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">终到时间</label>
		<div class="layui-input-inline">
			<input type="text" name="endTime" class="layui-input" id="endTime"
				readonly="readonly">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">运行状态</label>
		<div class="layui-input-inline">
			<select name="runState">
				<option value="">请选择</option>
				<option value="运行">运行</option>
				<option value="停运">停运</option>
			</select>
		</div>
	</div>
	<div class="layui-form-item">
		<div style="margin-left: 20px;">
			<button class="layui-btn" type="button" lay-submit lay-filter="add">添加</button>
			<button type="reset" class="layui-btn layui-btn-primary">重置</button>
		</div>
	</div>
</form>
<script type="text/javascript">
	layui.form.render('select');
	layui.laydate.render({
		elem : '#startTime',
		type : 'time',
		format : 'HH:mm'
	});
	layui.laydate.render({
		elem : '#endTime',
		type : 'time',
		format : 'HH:mm'
	});
	layui.form.on('submit(add)', function(data) {
		$.ajax({
			type : "POST",
			url : "sequence/add",
			data : data.field,
			async : true,
			dataType : "json",
			success : function(res) {
				let msg = "班次添加成功！"
				if (res.code === 0) {
					msg = "班次添加失败！"
				}else if (res.code === 2) {
					msg = "班次已经存在，不能再添加！"
				}else if(res.code === -3){
					msg = "数据验证失败！"
				}
				layer.open({
					content : msg,
				});
				if(res.code === 1){
					loadPage("sequence/showAll")
				}
			}
		});
		return false;
	});
</script>